
$(document).ready(function()
{	
	$("a[class='buyCoupon']").bind("click",function() 
	{		
		var couponID=$("#couponId").val();
		var couponName=$("#couponName").html();
		var couponPrice=$("#couponPrice").html();
		
		$.ajax(
		{
			type: 'get',
			url: edp_domain_url + 'ajax_log_info/?tiny=1',
			timeout: 5000,
			global:false,
			beforeSend: function()
			{
				$.blockUI(
				{ 
					message: '验证用户...',
					css: { padding:'5px',color:'#CC0000'}
				});
			},
			error: function()
			{
				$.blockUI(
				{ 
					message: '验证出错...',
					css: { padding:'5px',color:'#CC0000'}
				});
				$.unblockUI();
			},
		    success: function(data)
		    { 
				if(data!=false&&couponPrice==0)
				{
					//function defined in the popup_coupon.js
					getCoupon($('#PopBox'), 'action=buy&couponID='+couponID);
				}
				else
				{
					if(data==false)
					{   
						popupLogin($('#PopBox'),'兑换优惠券');           
					}
					else
					{
						//function defined in the popup_coupon.js
						popupCheckCoupon($('#PopBox'),couponID,couponName,couponPrice);
					} 
					$.blockUI(
					{ 
						message: $('#PopBox'),    
						css: 
						{ 
							padding:        0,
							margin:         0,
							top:            '30%', 
			        		left:           '35%', 
							width:          '',
							textAlign:      '', 
							color:          '', 
							border:         '',
							backgroundColor:'',       				
							cursor:         'wait'				        
						 }
					}); 	
				}
			}
		}); 
	});
});